<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="../jquery-1.4.4.js"></script>
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
<script type="text/javascript" src="qunit.js"></script>
<script type="text/javascript" src="../cscommon.js"></script>

<script>
	$(document).ready(function() {

		test("should return true if codeline starts with changed", function() {
			var changed = sourceChanged("changed: import com.imon.test");
			equals(changed, true, "Should return true for changed source line");
		});
		
		test("should return false if codeline doesnt start with changed", function() {
			var changed = sourceChanged("import com.imon.test");
			equals(changed, false, "Should return false for unchanged source line");
		});
		
		test("should return false for null and undefined codeline", function() {
			var changedForNull = sourceChanged(null);
			var changedForEmpty = sourceChanged("");
			equals(changedForNull, false, "Should return false for null source line");
			equals(changedForEmpty, false, "Should return false for empty source line");
		});
		
		test("should check string starts with", function() {
			var startsWith = "changed me".startsWith("chan");
			equals(startsWith, true, "Should return true");
		});
		
		test("should trim string", function() {
			var trimmedString = "codesphere".leftTrim(2);
			equals(trimmedString, "desphere");
		});
		
		test("should apply stylesheet on both lines if both original and revised codeline changes", function() {
			var originalline = "import com.imon";
			var revisedline = "import.com.imon.resource";
			
			var tr = getTr(1, "CHANGE", originalline, revisedline);
			equals(tr, "<tr><th>1</th><td class='old'>import com.imon</td><th>1</th><td class='new'>import.com.imon.resource</td></tr>");
		});
		
		test("should apply stylesheet on original if only original is changed", function() {
			var originalline = "import com.imon";
			var revisedline = "import.com.imon.resource";
			
			var tr = getTr(1, "DELETE", originalline, revisedline);
			equals(tr, "<tr><th>1</th><td class='old'>import com.imon</td><th>1</th><td class='noline'>import.com.imon.resource</td></tr>");
		});
		
		test("should apply stylesheet on revised if only revised is changed", function() {
			var originalline = "import com.imon";
			var revisedline = "import.com.imon.resource";
			
			var tr = getTr(1, "INSERT", originalline, revisedline);
			equals(tr, "<tr><th>1</th><td class='noline'>import com.imon</td><th>1</th><td class='new'>import.com.imon.resource</td></tr>");			
		});
		
		test("should not apply stylesheet if nothing changed", function() {
			var originalline = "import com.imon";
			var revisedline = "import com.imon.resource";
			
			var tr = getTr(1, "EQUAL", originalline, revisedline);
			equals(tr, "<tr><th>1</th><td class='none'>import com.imon</td><th>1</th><td class='none'>import com.imon.resource</td></tr>");
		});
	});
</script>

</head>
<body>
<h1 id="qunit-header">QUnit example</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
</body>
</html>